package com.lindroy.androidplayer.viewmodels

import com.lindroy.androidplayer.logic.network.repository.Repository
import com.lindroy.androidplayer.utils.SingleLiveEvent
import com.lindroy.androidplayer.utils.mapArticleData
import com.lindroy.androidplayer.utils.mapSingle

/**
 * @author Lin
 * @date 2022/3/8
 * @function
 */
class SearchResultViewModel : PageViewModel() {

    private val itemClickAction = SingleLiveEvent<ArticleItemViewModel>()

    val itemClickLiveData = itemClickAction.mapSingle { it }

    fun getSearchResult(keyword: String) =
        Repository.getSearchResult(keyword).mapArticleData(itemClickAction)
}